package cn.itcast.server.handler;

import cn.itcast.message.GroupListRequestMessage;
import cn.itcast.message.GroupListResponseMessage;
import cn.itcast.message.GroupMembersRequestMessage;
import cn.itcast.message.GroupMembersResponseMessage;
import cn.itcast.server.session.GroupSessionFactory;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Set;

/**
 * @Title: GroupListRequestMessageHandler
 * @Description:
 * @author: zdw
 * @date: 2022/2/18 17:09
 */


@ChannelHandler.Sharable
public class GroupListRequestMessageHandler extends SimpleChannelInboundHandler<GroupListRequestMessage> {
    @Override
    protected void channelRead0(ChannelHandlerContext ctx, GroupListRequestMessage msg) throws Exception {
        Set<String> groupName = GroupSessionFactory.getGroupSession()
                .getGroup();
        ctx.writeAndFlush(new GroupListResponseMessage(groupName));
    }
}
